import 'package:flutter/material.dart';
import 'package:flutter_basic_learning/utils/CommonWidget.dart';
import 'package:flutter_basic_learning/views/FlutterRoute/FlutterRoutePage.dart';
import 'package:get/get.dart';

class RoutePageOne extends StatefulWidget {
  final Object? arguments;
  const RoutePageOne({super.key, this.arguments});

  @override
  State<StatefulWidget> createState() => _RoutePageOneState();
}

class _RoutePageOneState extends State<RoutePageOne> {
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    print("get arguments: ${Get.arguments}");
    if (widget.arguments is Map) {
      final Map args = widget.arguments as Map;
      print("arguments: ${args}");
      print("arguments title: ${args['title']}");
    }
  }

  @override
  Widget build(BuildContext context) {
    return commonScaffold('RoutePageOne', [
      Center(
        child: ElevatedButton(
            onPressed: () {
              Navigator.of(context).pop();
              Navigator.pushReplacementNamed(context, '/pageOne');
              Navigator.of(context).pushAndRemoveUntil(
                  MaterialPageRoute(builder: (BuildContext context) {
                return const FlutterRoutePage(); //根页面
              }), (route) => false);
            },
            child: const Text(
              '返回',
            )),
      )
    ]);
  }
}
